<?php
namespace App\Http\Forms;

use Illuminate\Support\Facades\DB;
use Kris\LaravelFormBuilder\Form;

class BrandForm extends Form
{
    public function buildForm()
    {
//        $parent = [];
//        foreach (config('system.category') as $value) {
//            $parent[$value] = $value;
//        }
        // $parent = DB::select('SELECT * FROM categories WHERE PID =0 AND DELETED_AT IS NULL  ORDER BY SORT DESC');
        // $parent = array_column($parent, "name", "id");
        $this
            ->add('pid', 'select', [
                'label' => '父级分类',
                'rules' => 'required|string',
                'choices' => $this->getData("all_category") ?? [],
            ])
            ->add('name', 'text', [
                'label' => "品牌名",
                'rules' => 'required|string',
            ])
            ->add('submit', 'submit', [
                'attr' => ['class' => "form-control btn btn-success"],
                'label' => '保存',
            ]);
    }
}
